﻿using System.Configuration;
using System.Web.Mvc;
using System.Web.Routing;

namespace QunProject.Web
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            string Suffix = ConfigurationManager.AppSettings["Suffix"];

            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.MapRoute(
                name: "custom_action",
                url: "{controller}/{action}" + Suffix,
                defaults: new { controller = "Home", action = "Index" }
            );

            routes.MapRoute(
                name: "custom_id",
                url: "{controller}/{action}/{id}" + Suffix,
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "custom_attach",
                url: "{controller}/{action}/{id}/{attach}" + Suffix,
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional, attach = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "default",
                url: "{controller}/{action}/{id}/{attach}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional, attach = UrlParameter.Optional }
            );
        }
    }
}
